package com.lance.answer.gui.answer.gk.answer.lms.batch;

import com.google.common.collect.Maps;
import com.lance.answer.gui.answer.gk.answer.lms.batch.dto.LmsWatchDTO;
import com.lance.answer.gui.answer.gk.answer.lms.batch.task.LmsSaveVideoTask;
import com.lance.answer.gui.answer.gk.answer.lms.util.LmsUtil;
import org.apache.commons.io.IOUtils;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.concurrent.LinkedBlockingDeque;

public class LmsSaveVideoTmpppppp2 {

    public static void main(String[] args) throws Exception {


        int sync = 6;

        LinkedBlockingDeque<LmsWatchDTO> watchQueue = new LinkedBlockingDeque<>();

        InputStream inputStream2 = new FileInputStream("libs//2022秋//fengx.user");
        List<String> userString = IOUtils.readLines(inputStream2, "utf-8");

        for (String user : userString) {
            String[] strs = user.split(",");
            String userCode = strs[0];
            String pwd = strs[1];
            LmsWatchDTO lmsWatchDTO = new LmsWatchDTO();
            lmsWatchDTO.setUsername(userCode);
            lmsWatchDTO.setPassword(pwd);
//            if(!LmsUtil.getVip().contains(userCode)){
//                continue;
//            }
            if(
                    !"2211001201588".equals(userCode)
            ){
                continue;
            }

            Map<Long, String> getUserCourseMap = Maps.newHashMap();
            getUserCourseMap.clear();
            getUserCourseMap.put(10000002577l, "中国近现代史纲要");
            getUserCourseMap.put(10000002567l, "形势与政策");
         //   getUserCourseMap.put(10000003958l, "形势与政策");
//            lmsWatchDTO.setCourseMap(getUserCourseMap);
            lmsWatchDTO.setCourseMap(getUserCourseMap);

            watchQueue.add(lmsWatchDTO);
        }

        for (int i = 1; i <= sync; i++) {
            Thread answerThread = new LmsSaveVideoTask("d:\\ynouAutoStudy\\chromedriver.exe", watchQueue);
            //log.info("加载课程ID：{} 名称：{} ", openCourseId,subjectName);
            answerThread.setName("答题线程--" + i);
            answerThread.start();
        }


    }



}
